/*
 * @Author: c
 * @Date: 2023-11-30 08:42:33
 * @LastEditTime: 2023-12-16 07:18:15
 * @LastEditors: c
 * @Description: 
 * @FilePath: \music-web-backend\src\auth\auth.controller.ts
 * https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { Body, Controller, Post, HttpCode, HttpStatus, UseGuards, Get, Request, UseFilters, UseInterceptors, ClassSerializerInterceptor } from '@nestjs/common';
import { AuthService } from './auth.service';
// import { AuthGuard } from './auth.guard';
import { SkipAuth } from './constants';
import { AuthGuard } from '@nestjs/passport';
import { JwtAuthGuard } from './guard/jwt-auth.guard';
import { User } from 'src/core/system/user/entities/user.entity';

@Controller('auth')
export class AuthController {
    constructor(private authService: AuthService) { }

    /**
     * 登录
     * @param signInDto 
     * @returns 
     */
    // @SkipAuth()
    // @UseGuards(AuthGuard('local'))
    // @HttpCode(HttpStatus.OK)
    // @Post('login')
    // signIn(@Body() signInDto: Record<string, any>) {

    //     return this.authService.signIn(signInDto.username, signInDto.password);
    // }
    @SkipAuth()
    @UseGuards(AuthGuard('local'))
    @HttpCode(HttpStatus.OK)
    @Post('login')
    // @UseFilters(new HttpExceptionFilter())
    signIn(@Request() req,@Body() body) {

        

        return req.user
    }

   
   
    @UseGuards(JwtAuthGuard)  //权限守卫
    @Get('profile')
    getProfile(@Request() req) {
        return req.user;
      
    }

}